import { createStore, compose, combineReducers, applyMiddleware } from 'redux';
// import thunkMiddleware from 'redux-thunk'
// import dynamic from './dynamicreducer' 动态
import login from './reducer/loginreducer'
import shop from './reducer/shopreducer'
import shoucang from './reducer/shoucangreducer'
// import toke from './tokereducer'
import message from './reducer/messagereducer'
import conversation from './reducer/conversationreducer'
import yuding from './reducer/yudingreducer'
import business from './reducer/busreducer'
import shop_temp from './reducer/shop_tempreducer'
import county from './reducer/countyreducer'
import user from './reducer/userreducer'
import comment from './reducer/commentreducer'
import dynamic from './reducer/dynamicreducer'
import report from './reducer/reportreducer'
import feedback from './reducer/feedbackreducer'

let rootReducer = combineReducers({
    feedback, report, shoucang, login, shop, yuding, business, shop_temp, county, conversation, message, user, comment, dynamic
})

function logger({ getState }) {
    return (next) => (action) => {
        let returnValue = next(action)
        return returnValue
    }
}
const thunk = ({ dispatch, getState }) => (next) => (action) => {
    if (typeof action === 'function') {
        return action(dispatch, getState);
    }
    return next(action);
};

// const createStoreWithMiddleware = applyMiddleware(loggerMiddleware, thunkMiddleware)(createStore)
const store = createStore(
    rootReducer,
    // createStoreWithMiddleware,
    compose(
        applyMiddleware(logger, thunk),
        window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
    )
);

export default store;